/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Image,
    ListView,
    TouchableOpacity
} from 'react-native';

var LazyInterestedCell =require('./LazyInterestedCell');
var dataAttr = require('../../../LocalData/interested.json');
var LazyInterestedList = React.createClass({
    getInitialState(){
        var ds = new ListView.DataSource({rowHasChanged:(row1, row2) => row1 !== row2});

        return{
            dataSource: ds.cloneWithRows(dataAttr)
        }
    },
    render() {
        return (
            <ListView
            dataSource={this.state.dataSource}
            renderRow={this.renderRows}
            />
        );
    },
    // 具体的cell
    renderRows(rowdata,sectionID,rowID){

        var styleName = (parseInt(rowID) + 1) % 2 == 0 ?{marginBottom:10}:{};
        return(
            <View
                style = {styleName}
            >
            <LazyInterestedCell
                name={rowdata.name}
                avatar={rowdata.avat}
                distance={rowdata.distance}
                unit={rowdata.unit}
                detail={rowdata.detail}
            />
            </View>
        );
    }
});
const styles = StyleSheet.create({
    container: {
        flex:1
    },
});
module.exports = LazyInterestedList;